<html>
<head><meta charset="utf-8"><title>mutating options during the compilation · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/mutating.20options.20during.20the.20compilation.html">mutating options during the compilation</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="136179041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/mutating%20options%20during%20the%20compilation/near/136179041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/mutating.20options.20during.20the.20compilation.html#136179041">(Oct 20 2018 at 18:12)</a>:</h4>
<p>So, I’m done implementing <code>optimize(size)</code> and am now working on <code>optimize(speed)</code>, however I’m stuck with a weird question: can I mutate session options (<code>sess.opts</code>)?</p>



<a name="136179190"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/mutating%20options%20during%20the%20compilation/near/136179190" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/mutating.20options.20during.20the.20compilation.html#136179190">(Oct 20 2018 at 18:17)</a>:</h4>
<p>namely, in typeck/collect.rs all the <code>optimize(...)</code> attributes are collected and if any of the attributes are <code>optimize(speed)</code>, the crate must unconditionally be compiled with <code>-Copt-level=1/2/3</code>.</p>



<a name="136179249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/mutating%20options%20during%20the%20compilation/near/136179249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/mutating.20options.20during.20the.20compilation.html#136179249">(Oct 20 2018 at 18:18)</a>:</h4>
<p>Are there any possible complications with me just doing <code>sess.opts.optimize = X;</code> from typeck/collect.rs wrt incremental compilation or query system?</p>



<a name="136278255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/mutating%20options%20during%20the%20compilation/near/136278255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/mutating.20options.20during.20the.20compilation.html#136278255">(Oct 22 2018 at 16:28)</a>:</h4>
<blockquote>
<p>So, I’m done implementing <code>optimize(size)</code> and am now working on <code>optimize(speed)</code>, however I’m stuck with a weird question: can I mutate session options (<code>sess.opts</code>)?</p>
</blockquote>
<p>I don't think you can :)</p>



<a name="136278258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/mutating%20options%20during%20the%20compilation/near/136278258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/mutating.20options.20during.20the.20compilation.html#136278258">(Oct 22 2018 at 16:29)</a>:</h4>
<blockquote>
<p>Are there any possible complications with me just doing <code>sess.opts.optimize = X;</code> from typeck/collect.rs wrt incremental compilation or query system?</p>
</blockquote>
<p>heck yes there is</p>



<a name="136278272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/mutating%20options%20during%20the%20compilation/near/136278272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/mutating.20options.20during.20the.20compilation.html#136278272">(Oct 22 2018 at 16:29)</a>:</h4>
<p>in particular, we assume that the result of a given query is deterministic,</p>



<a name="136278300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/mutating%20options%20during%20the%20compilation/near/136278300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/mutating.20options.20during.20the.20compilation.html#136278300">(Oct 22 2018 at 16:29)</a>:</h4>
<p>mutating accessible state like the options could mean that the query would change its result</p>



<a name="136278306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/mutating%20options%20during%20the%20compilation/near/136278306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/mutating.20options.20during.20the.20compilation.html#136278306">(Oct 22 2018 at 16:29)</a>:</h4>
<p>without any of the other queries or inputs changing their output</p>



<a name="136278311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/mutating%20options%20during%20the%20compilation/near/136278311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/mutating.20options.20during.20the.20compilation.html#136278311">(Oct 22 2018 at 16:29)</a>:</h4>
<p>that would basically mess everything up :)</p>



<a name="136278384"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/mutating%20options%20during%20the%20compilation/near/136278384" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/mutating.20options.20during.20the.20compilation.html#136278384">(Oct 22 2018 at 16:30)</a>:</h4>
<p>in general, <code>sess.opts</code> is just bad (as is most of <code>Session</code>) and all of that should eventually become queries</p>



<a name="136287311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/mutating%20options%20during%20the%20compilation/near/136287311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/mutating.20options.20during.20the.20compilation.html#136287311">(Oct 22 2018 at 19:02)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> so the "actual" optimsation level (the one given to LLVM) would probably become a query itself, right?</p>



<a name="136287317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/mutating%20options%20during%20the%20compilation/near/136287317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/mutating.20options.20during.20the.20compilation.html#136287317">(Oct 22 2018 at 19:02)</a>:</h4>
<p>yes, that would be ideal</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>